#ifndef DATABASE_H
#define DATABASE_H

#include <QObject>
#include <QtSql/QSqlQuery>
#include <QtSql/QSqlDatabase>
#include <QList>
#include "ChatterBoxServer.h"

class ChatterBoxServer;

struct user
{
    QString name;
    int score;
    bool operator<(const user other) const;
};

class Database : public QObject
{
    Q_OBJECT
public:
    Database(ChatterBoxServer *server);
    ~Database();
    bool SQLuserExist(QString name);
    void SQLaddUser(QString name, int score);
    void SQLsetScore(QString name, int score);
    int SQLgetScore(QString name);
    void SQLaddScore(QString name, int score);
    void addUser(QString name, int score);
    void setScore(QString name, int score);
    int getScore(QString name);
    void addScore(QString name, int score);
    void SQLreloadUsers();
    int getRank(QString name);
    bool userExists(QString name);
    void showTop3();
    void showScore(QString name);
    QList<user> usersList;
private:
    QSqlDatabase db;
    ChatterBoxServer* chatSrv;
signals:

public slots:

};

#endif // DATABASE_H
